package com.fz.us.admin.company.entity;




import javax.persistence.*;
import java.util.Set;

/**
 * 实体类 - 职权
 * ============================================================================
 * 版权所有 2016 。
 *
 * @author fallenpanda
 * @version 1.0 2016-08-11 。
 * ============================================================================
 */
@Entity
@Table(name="sys_power")
@AttributeOverride(name = "name", column = @Column(name = "name"))
public class Power extends CompanyEntity {

    private static final long serialVersionUID = 1457644074767751323L;
    /**
     * 令牌(要舍弃)
     */
    private String value;
    /**
     * 部门
     */
    private Department department;
    /**
     * 岗位
     */
    private Post post;

    /**
     * 描述
     */
    private String description;


    /**
     * 父节点
     */
    private Power parent;

    /**
     * 子节点
     */
    private Set<Power> children;



    @ManyToOne(fetch = FetchType.LAZY)
    public Department getDepartment() {
        return department;
    }

    public void setDepartment(Department department) {
        this.department = department;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    public Post getPost() {
        return post;
    }

    public void setPost(Post post) {
        this.post = post;
    }



    @ManyToOne(fetch = FetchType.LAZY)
    public Power getParent() {
        return parent;
    }

    public void setParent(Power parent) {
        this.parent = parent;
    }

    @OneToMany(mappedBy = "parent",fetch = FetchType.LAZY)
    @OrderBy("name asc")
    public Set<Power> getChildren() {
        return children;
    }

    public void setChildren(Set<Power> children) {
        this.children = children;
    }

    @Column(length = 5000)
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
